App({
  onLaunch: function () {
    if (!wx.cloud) {
      console.error('版本过低')
    } else {
      wx.cloud.init({
        env: 'epms-aocnh',
        traceUser: true, 
      }) 
    }

    //判断是否授权过
    var user = wx.getStorageSync("userInfo");
    if(user){
      this.globalData.isLogin = true;
      this.globalData.userInfo = user;
    }

    //判断保安是否登录
    var police = wx.getStorageSync("police");
    if(police&&police.login){
      // this.globalData.policeName = police.name;
      //重定向
      wx.redirectTo({
        url: '/pages/policelogin/scan/scan?name=' + police.name,
      })
    }

    //判断学生是否登录
    var student = wx.getStorageSync("student");
    if (student&&student.login) {
      this.globalData.studentID = student.studentID
      wx.switchTab({
        url: '/pages/index/index?studentID=' + student.studentID,
      })
    }

    //判断老师是否登录
    var teacher = wx.getStorageSync("teacher");
    if (teacher && teacher.login) {
      this.globalData.teacherID = teacher.teacherID;
      this.globalData.teacherName = teacher.name;
      //重定向
      wx.redirectTo({
        url: '/pages/teacherlogin/home/home',
      })
    }
  },
  
  globalData:{
    userInfo:null,
    isLogin:false,
    studentID:null,  //address使用
    name:null,
    grade:"",
    // policeName:null,
    peoplenum:"",
    reason:"",
    phone:"",
    userid:"",
    teacherID:'请刷新',
    teacherName:null,
    
  }
})
